1. Field of the Invention
The present invention relates to a variable-length coding method, a variable-length coding device and an imaging system, which are realized in the MPEG mode, for coding picture data or the like.
2. Description of the Prior Art
Technologies for compressing picture data at a high compression rate have been advanced and used for digital cameras and digital video cameras.
For example, as a method for compressing moving picture data, the MPEG (moving picture experts groups) method standardized by ISO has been known in general. The MPEG method is characterized in that coding using an intraframe correlation (which will be hereafter referred to as “intracoding”) or coding using an interframe correlation (which will be hereafter referred to as “interceding”) is performed for each block (which will be hereafter referred to as “macroblock”) including a plurality of pixels and constituting a frame.
In the above-described types of coding, specifically, DCT (discrete cosine transform) which is a quadrature transform is performed to data in a macroblock and then quantization and variable-length coding are performed thereto, thereby compressing picture data.
In variable-length coding (VLC processing) using VLC (variable-length code), assuming that Run indicating the number of zero coefficients before a non-zero coefficient, Level indicating a non-zero coefficient value, and Last indicating whether or not the non-zero coefficient is the last coefficient form a group (coefficient series), a DCT coefficient obtained as a result of DCT is coded by uniquely allocating a code to the group (Last, Run, Level). In MPEG compression, a variable-length coding is performed using a VLC table defined for the purpose of allocation of a unique code.
When variable-length coding is performed using a VLC table but a VLC corresponding to the group (Last, Run, Level) is not defined in the VLC table, coding is performed with application of the following three escape modes.
In a first escape mode, NewLevel is obtained as a new Level for the group (Last, Run, Level) by subtracting LMAX which is a maximum value of Level corresponding to Last and Run in a VLC table from an absolute value of Level and then putting the sign of Level to a result of the subtraction. Then, VLC processing is performed again, this time, to a group (Last, Run, NewLevel) using the VLC table.
The following is an equation for obtaining NewLevel.NewLevel=sign(Level)×(|Level|−LMAX)where sign (Level) is the sign of Level and |Level| is an absolute value of Level.
In a second escape mode, NewRun is obtained as a new Run for the group (Last, Run, Level) by subtracting a value obtained by adding 1 to RMAX which is a maximum value of Run corresponding to Last and Level in the VLC table from a value of Run. Then, VLC processing is performed again, this time, to a group (Last, NewRun, Level) using the VLC table.
The following is an equation for obtaining NewRun.NewRun=Run−(RMAX+1)
In a third escape mode, the group (Last, Run, Level) is transformed to FLC (fixed length code).
FIG. 31 is a flow chart schematically showing the order in which process steps are performed and a flow of information (signal) in each process step.
First, VLC processing is performed to a group (Last, Run, Level) and, if the group is successfully coded, a code (effective code) is output (Step S1).
Whether or not the output code is an effective code is judged (Step S2) and, if it is judged that the output code is an effective code, the code is output and coding is completed (Step S3).
If coding is not completed in Step S1, whether or not the first escape mode has been already performed using LMAX is judged (Step S4).
If the first escape mode has not been performed, NewLevel is obtained by calculation using the equation for obtaining NewLevel to generate a group (Last, Run, NewLevel) (Step S5) and then the VLC processing of Step S1 is performed again. Whether or not the output code is an effective code is judged (Step S2) and, if it is judged that the output code is an effective code, the code is output and coding is completed (Step S3).
If coding is not completed in Step S4, whether or not the second escape mode has been already performed using RMAX is judged (Step S6).
If the second escape mode has not been performed, NewRun is obtained by calculation using the equation for obtaining NewRun to generate a group (Last, NewRun, Level) (Step S7) and then the VLC processing of Step S1 is performed again. Whether or not the output code is an effective code is judged (Step S2) and, if it is judged that the output code is an effective code, the code is output and coding is completed (Step S3).
If coding is not completed in Step S6, transform (FLC processing) is performed to the group (Last, Run, Level) to obtain FLC (fixed-length code) (Step S8). Then, a result of the FLC processing is output and coding is completed (Step S3).
As described above, in VLC processing in the known MPEG compression, with a cycle in which an output result is obtained using a VLC table assumed to be 1 cycle, three cycles are required to obtain FLC. That is, in the case of data needing FLC processing to be performed for many times, many processing cycles are required, so that the problem of reduction in processing speed arises.
As a method for realizing coding with fewer cycles even for data needing FCL processing to be performed for many times, a processing method with procedures shown in FIG. 32 has been proposed (see, for example, Japanese Patent Publication No. 3573735).
In this method, separate processing steps for FLC processing are parallelly performed. That is, VCL processing for a received group (Last, Run, Level), VLC processing for a group (Last, Run, NewLevel) newly generated by calculation using the equation for obtaining NewLevel in the first escape mode, VLC processing for a group (Last, NewRun, Level) newly generated by calculation using the equation for obtaining NewRun in the second escape mode, and FLC processing for the group (Last, Run, Level) in the third escape mode are performed in parallel.
In a system which realizes processing according to the above-described method, three separate VLC processing are parallelly performed, and therefore three VLC tables in total are provided in the system.
For outputs by the above-described three VLC processing as well as outputs by some other VCL processing, a single output is selected according to predetermined priorities.
According to this method, if a processing cycle of a VLC table is assumed to be 1 cycle, coding can be completed in 1 cycle.
However, in the above-described method in which three VLC processing are performed in parallel, a processing cycle of coding is reduced but three parallel VLC tables have to be provided. Therefore, a circuit size in a coding system for realizing this method is unexpectedly increased.